package com.kgc.springboot.aviation.service.zzy.Impl;

import com.kgc.springboot.aviation.mapper.MenuMapper;
import com.kgc.springboot.aviation.pojo.Menu;
import com.kgc.springboot.aviation.pojo.MenuExample;
import com.kgc.springboot.aviation.service.zzy.MenuServices;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MenuServicesImpl implements MenuServices {
    @Resource
    MenuMapper menuMapper;
    @Override
    public int add(Menu menu) {
        return menuMapper.insertSelective(menu);
    }

    @Override
    public Menu getAll(Integer id) {
        MenuExample example=new MenuExample();
       if (id!=null&&id>0){
           example.createCriteria().andIdEqualTo(id);
           List<Menu> menus = menuMapper.selectByExample(example);
           if (menus!=null&&menus.size()>0){
               return menus.get(0);
           }
       }
        return null;
    }

    @Override
    public int upDate(Menu menu) {
        return menuMapper.updateByPrimaryKeySelective(menu);
    }
}
